<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:doc="livcos.org/ns/doc"
  xmlns:pm="livcos.org/ns/pm"
  xmlns="http://www.w3.org/1999/xhtml"
  exclude-result-prefixes="doc pm">

  <xsl:template match="pm:todo">
    <table border="0" cellspacing="0" cellpadding="2" class="todo">
      <tr>
        <th class="sorter" onclick="sort(this,'@priority')">Priority</th>
        <th class="sorter" onclick="sort(this,'pm:title')">Title</th>
        <th class="sorter" onclick="sort(this,'pm:description')">Description</th>
        <th class="sorter" onclick="sort(this,'@progress')">Progress</th>
      </tr>
      <xsl:apply-templates select="pm:task">
        <xsl:sort select="@priority" order="descending"/>
        <xsl:sort select="pm:title" order="ascending"/>
        <xsl:sort select="@progress" order="ascending"/>
      </xsl:apply-templates>
    </table>
  </xsl:template>
  
	<xsl:template match="pm:todo/pm:task">
		<tr id="{@id}" class="todo_task">
			<td class="todo_priority">
				<xsl:value-of select="@priority" />
			</td>
			<td class="todo_title">
				<xsl:value-of select="pm:title" />
			</td>
			<td>
				<xsl:apply-templates select="pm:description/node()" />
			</td>
			<td align="center">
				<div class="progress_box" align="left">
					<xsl:if test="@progress &gt; -10">
						<div class="progress_bar">
							<xsl:attribute name="style">width:<xsl:value-of select="@progress" />%;</xsl:attribute>
							<xsl:text>&#160;</xsl:text>
						</div>
					</xsl:if>
				</div>
			</td>
		</tr>
	</xsl:template>
	
</xsl:stylesheet>
